﻿#ifndef COMBOBOX_H
#define COMBOBOX_H

#include <QComboBox>
#include <QPainter>
#include <QStyledItemDelegate>
#include <QListView>
#include <QEvent>
#include <QPaintEvent>

class ItemDelegate : public QStyledItemDelegate
{
    Q_OBJECT

public:
    explicit ItemDelegate(QObject *parent = nullptr);
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};

class ComboBox : public QComboBox
{
    Q_OBJECT

public:
    explicit ComboBox(QWidget *parent = nullptr);
    void setBackgroundColor(const QColor &color);
    void setBorderRadius(int radius);
    void setBorderColor(const QColor &color);
    void setIcon(const QIcon &icon);

protected:
    void paintEvent(QPaintEvent *event) override;
    void showPopup() override;
    bool eventFilter(QObject *obj, QEvent *event) override;

private:
    QColor m_backgroundColor;
    int m_borderRadius;
    QColor m_borderColor;
    QIcon m_icon;
};

#endif // COMBOBOX_H
